package com.gitee.wsl.common.more.ext.dialog

import com.gitee.wsl.android.ui.ext.ApplicationScope
import com.gitee.wsl.common.ui.theme.ColorPaletteScheme
import com.gitee.wsl.common.ui.theme.Theme
import com.gitee.wsl.common.ui.theme.TypographyScheme
import com.gitee.wsl.android.ui.theme.inject.useTheme
import com.lxj.xpopup.XPopup

object XPopupExt {
}

fun <P: com.gitee.wsl.common.ui.theme.ColorPaletteScheme,T: com.gitee.wsl.common.ui.theme.TypographyScheme,THEME: Theme<P, T>> ApplicationScope.useXPopup(theme:THEME){
    val scheme=theme.colorScheme.toAndroid()
    XPopup.setPrimaryColor(scheme.primary)
    XPopup.setShadowBgColor(scheme.shadow)
}

fun <P: com.gitee.wsl.common.ui.theme.ColorPaletteScheme,T: com.gitee.wsl.common.ui.theme.TypographyScheme,THEME: Theme<P, T>> XPopup.Builder.theme(theme:THEME) {
    useTheme(this, theme.colorScheme.toAndroid()) { scheme ->
        XPopup.setPrimaryColor(scheme.primary)
        shadowBgColor(scheme.shadow)
    }
}